// AccountMapper.java
package com.example.mapper;

import com.example.POJO.Account;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AccountMapper {
    // select all accounts
    @Select("select * from account")
    List<Account> getAllAccounts();
    @Insert("INSERT INTO account (phone, password) VALUES (#{phone}, #{password})")
    void insertAccount(Account account);

    @Select("SELECT password FROM account WHERE phone=#{phone}")
    String getPasswordByPhone(String phone);

    @Select("SELECT id FROM account WHERE phone=#{phone}")
    Integer getIdByPhone(String phone);
    @Update("update account set password=#{password} where id=#{id}")
    void updatePassword(Account account);
    @Select("SELECT id FROM unity_account WHERE phone=#{phone}")
    Integer getIdByPhoneUnity(String phone);
    @Insert("INSERT INTO unity_account (phone, password) VALUES (#{phone}, #{password})")
    void insertUnityAccount(Account account);

    @Select("SELECT password FROM unity_account WHERE phone=#{phone}")
    String getPasswordByPhoneUnity(Account account);
    @Update("update unity_account set password=#{password} where phone=#{phone}")
    void updatePasswirdUnity(Account account);
}
